<div class="SipeiMain_r fr">
    <h2 class="clearfix fonts_18 height45 fontc_444"><?php echo $this->title;?></h2>
    <div class="clearfix back_bgf border_3 border_c pr30 pt20 pb20 height32 fontc_666">
    <?php
    $form = $this->beginWidget('CActiveForm', array(
    'action' => $this->createUrl('/problem/default/export'),
    'method' => 'POST',
    'id' => 'myform',
    'htmlOptions' => array('target' => 'ajax-frame')
    ));
    ?> 
           <table>
                <tbody>
                    <tr>
                        <td width="200" align="right" class="pt10 pr5">考试项目：</td>
                        <td width="558" class="pt10">
                            <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3">
                                <span class="fl select_shelter">
                                    <select class="fl fontc_666" id="exam_id" name="info[exam_id]" onchange="getSubject(this.value)">
                                    	<?php if (isset($data['exam'])):?>
                      					<?php foreach($data['exam'] as $value):?>
                        					<option value="<?php echo $value['exam_id']?>"><?php echo $value['exam_term_name']?></option>
                        				<?php endforeach;?>
                        				<?php else :?>
                        				<option value="">没有项目</option>
                        				<?php endif;?>
                      				</select>
									<input type="hidden" id="exam_name" name="info[exam_name]" value="1">
                                </span>
                            </span>
                        </td>
                    </tr>
                    <tr>
                        <td align="right" class="pt10 pr5">导出规则：</td>
                        <td class="pt10">
                            <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3">
                                <span class="fl select_shelter">
                                    <select class="fl fontc_666" name="info[problem_id]">
                                    	<?php if (isset($data['problemrule'])):?>
                      					<?php foreach($data['problemrule'] as $value):?>
                        					<option value="<?php echo $value['id']?>"><?php echo $value['name']?></option>
                        				<?php endforeach;?>
                        				<?php else :?>
                        				<option value="">没有规则</option>
                        				<?php endif;?>
                      				</select>
                                </span>
                            </span>
                        </td>
                    </tr>
                    
                    <tr>
                        <td valign="top" align="right" class="pt10 pr5">是否单独生成excel表格：</td>
                        <td class="pt10 height20">
                        	<ul class="fl OutList">
                        	
                                    <li class="fl pt8 pr20 pb5">
                                        <input type="checkbox" id="is_exports" value="1" name="info[is_sheet]" class="fl checkbox">
                                    </li>
             
                                </ul>
                        </td>
                    </tr>
                    
                    <tr>
                        <td valign="top" align="right" class="pt10 pr5">学校：</td>
                        <td class="pt10 height20">
                        	<ul class="fl OutList" id="changeSchool">
                        	<!-- 
                        				<?php if($data['school']):?>
                        	<?php foreach ($data['school'] as $k=>$v):?>
                                    <li class="fl pt8 pr20 pb5">
                                        <input type="checkbox" value="<?php echo $v['school_id'];?>" checked name="info[school][]" class="fl checkbox">
                                        <span class="fl pl5"> <?php echo $v['school_name'];?></span>
                                    </li>
                                <?php endforeach;?>	
                                <?php endif;?> -->	
                                </ul>
                        </td>
                    </tr>
                    <tr>
                        <td valign="top" align="right" class="pt10 pr5">科目：</td>
                        <td class="pt10 height20">
                        	<ul class="OutList" id="changeSubjects">
                    		<!-- <?php if($data['school']):?>
                        	<?php foreach ($data['subject'] as $k=>$v):?>
                                    <li class="fl pt8 pr20 pb5">
                                     <input type="checkbox" value="<?php echo $v['subject_id'];?>" checked name="info[subject][]" class="fl checkbox">
                                     <span class="fl pl5"> <?php echo $v['subject_name'];?></span>
                                 </li>
                             <?php endforeach;?>	
                             <?php endif;?>	-->
                             </ul>
                        </td>
                    </tr>
                    <tr>
                        <td colspan='2' class="pt10 text_align">
                            <input type="submit" name="submit" value="导出" class="b_a_n border_3 back_bgfb w80 height32 fontc_FFF fonts_12 mr10 cursor" />
                        </td>
                    </tr>
                </tbody>
            </table>
        <?php
    $this->endWidget();
    ?>
    </div>            
</div>
<iframe src='' style="display:none" name='ajax-frame'></iframe>
<script>
function getSubject(val){
	if(val!=''){
		$.post('/export/results/getexam', {id: val}, function(result) {
			var dataObj=eval("("+result+")");//转换为json对象
			var schoolstr = "";
			
			$.each(dataObj.school,function(i,item){
				schoolstr += "<li class='fl pt8 pr20 pb5'><input type='checkbox' value='" + item.school_id + "' checked name='info[school][]' class='fl checkbox'><span class='fl pl5'>" + item.school_name+ "</span> </li>";
			})
			
			$("#changeSchool").html(schoolstr);

		
			var subjectstr = "";
			$.each(dataObj.suject,function(i,item){
				subjectstr += "<li class='fl pt8 pr20 pb5'><input type='checkbox' value='" + item.subject_id + "' checked name='info[subject][]' class='fl checkbox'><span class='fl pl5'> " + item.subject_name + "</span></li>";
			})
			$("#changeSubjects").html(subjectstr);
		})
		var examName;
		examName = $("#exam_id option[value="+val+"]").html();
		$("#exam_name").val(examName);
	}
}
function exports(){
	if($("#is_exports").attr('checked') == 'checked'){
		$("#myform").attr("action",'/problem/default/exports');
		$("#myform").attr("target",'_blank');
	}else{
		$("#myform").attr("action",'/problem/default/export');
		$("#myform").attr("target",'');
	}
}

<?php if (isset($data['exam'])):
   echo "getSubject(".$data['exam'][0]['exam_id'].")"; 
 endif;?>
</script>